const util = require('../../utils/util.js');
const api = require('../../config/api.js');
Page({
  data: {
    list: [],
    page:1,
    totalPages:1,
  },
  onShareAppMessage() {
    return {};
  },
  onLoad() {
    this.getIndexData();
  },
  getIndexData() {
    let that = this;
    util.request(api.FeeList,{pageRequestVo: {pageNum: this.data.page, pageSize: 10}},'POST').then(function(res) {
      if (res.errno === 200) {
        that.setData({
          list: that.data.list.concat(res.data.list||[]),
          totalPages:res.data.pages
        });
      }
    });
  },
  onPullDownRefresh() {
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  onReachBottom() {
    if ( this.data.page < this.data.totalPages ) {
      this.setData({
        page: this.data.page + 1
      });
      this.getIndexData();
    } else {
      wx.showToast({
        title: '没有更多了',
        icon: 'none',
        duration: 2000
      });
      return  false;
    }
  },
  view_17OnClick() {
    wx.navigateTo({ url: '/pages/ReceiptPreview/ReceiptPreview' });
  },
});
